package com.warmheart.builder.secret;

import com.warmheart.core.co.base.BaseCoBuilder;
import com.warmheart.core.co.oper.Co;
import com.warmheart.core.cors.enums.DateFormatEnum;
import com.warmheart.entity.secret.SecretKey;

/**
 * 
 * @ClassName: SecretKey
 * @Description: 密钥实体CoBuilder类，对应表名称为tb_secret_key 温馨提示：不要修改该实体CoBuilder类的任何字段
 * @author ZhangJianyang
 * @date 2025年06月16日 下午13:05:35
 *
 */
public class SecretKeyCoBuilder extends BaseCoBuilder<SecretKey, SecretKeyCoBuilder> {

    private final SecretKey t;

    @Override
    protected SecretKeyCoBuilder self() {
        return this;
    }

    @Override
    public SecretKey core() {
        return this.t;
    }

    public SecretKeyCoBuilder(SecretKey secretKey) {
        t = secretKey;
    }

    /**
     * 密钥名称
     */
    private Co<SecretKey, SecretKeyCoBuilder> name;

    /**
     * 密钥类型
     */
    private Co<SecretKey, SecretKeyCoBuilder> keyType;

    /**
     * 加密后的密钥内容
     */
    private Co<SecretKey, SecretKeyCoBuilder> encryptedKey;

    /**
     * 加密向量
     */
    private Co<SecretKey, SecretKeyCoBuilder> encryptionIv;

    /**
     * 密钥描述
     */
    private Co<SecretKey, SecretKeyCoBuilder> description;

    /**
     * 所属用户ID
     */
    private Co<SecretKey, SecretKeyCoBuilder> ownerId;

    /**
     * 是否激活
     */
    private Co<SecretKey, SecretKeyCoBuilder> state;

    /**
     * 过期时间
     */
    private Co<SecretKey, SecretKeyCoBuilder> expiresTime;

    public Co<SecretKey, SecretKeyCoBuilder> name() {
        if (this.name == null) {
            this.name = new Co<SecretKey, SecretKeyCoBuilder>(self(), "name");
        }
        return this.name;
    }

    public Co<SecretKey, SecretKeyCoBuilder> keyType() {
        if (this.keyType == null) {
            this.keyType = new Co<SecretKey, SecretKeyCoBuilder>(self(), "key_type");
        }
        return this.keyType;
    }

    public Co<SecretKey, SecretKeyCoBuilder> encryptedKey() {
        if (this.encryptedKey == null) {
            this.encryptedKey = new Co<SecretKey, SecretKeyCoBuilder>(self(), "encrypted_key");
        }
        return this.encryptedKey;
    }

    public Co<SecretKey, SecretKeyCoBuilder> encryptionIv() {
        if (this.encryptionIv == null) {
            this.encryptionIv = new Co<SecretKey, SecretKeyCoBuilder>(self(), "encryption_iv");
        }
        return this.encryptionIv;
    }

    public Co<SecretKey, SecretKeyCoBuilder> description() {
        if (this.description == null) {
            this.description = new Co<SecretKey, SecretKeyCoBuilder>(self(), "description");
        }
        return this.description;
    }

    public Co<SecretKey, SecretKeyCoBuilder> ownerId() {
        if (this.ownerId == null) {
            this.ownerId = new Co<SecretKey, SecretKeyCoBuilder>(self(), "owner_id");
        }
        return this.ownerId;
    }

    public Co<SecretKey, SecretKeyCoBuilder> state() {
        if (this.state == null) {
            this.state = new Co<SecretKey, SecretKeyCoBuilder>(self(), "state");
        }
        return this.state;
    }

    public Co<SecretKey, SecretKeyCoBuilder> expiresTime(DateFormatEnum... dateFormatEnums) {
        if (this.expiresTime == null) {
            if (dateFormatEnums != null && dateFormatEnums.length > 0) {
                this.expiresTime = new Co<SecretKey, SecretKeyCoBuilder>(self(), "expires_time",
                        dateFormatEnums[0].getValue());
            } else {
                this.expiresTime = new Co<SecretKey, SecretKeyCoBuilder>(self(), "expires_time",
                        DateFormatEnum.yyyy_MM_dd.getValue());
            }
        }
        return this.expiresTime;
    }
}